import elementtree.ElementTree as ET
import string

class notes_parser:
   def __init__(self,notes):
      self.notes = notes
      
   def parse(self,keyword = None):
      result = []
      for i in range(len(self.notes)):
         root = ET.fromstring(str(self.notes[i]))
         
         iterindex = 0
         iter = root.getiterator()
         for element in iter:
            iterindex = iterindex + 1
            if element.tag == "input_heading":
               index = str(element.text).lower().find(keyword)
               if index != -1 :
                  #print element.text, "found"
                  if iter[iterindex].tag == "input_text":
                     result.append(iter[iterindex].text)
      return result
